home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Str / s / strcatcr next >
Encoding:
Text File  |  1995-08-26  |  2.0 KB  |  67 lines

  1. ;   ####             #    #     # #
  2. ;   #   #            #    #       #          The FreeWare C library for
  3. ;   #   #  ##   ###  #  # #     # ###             RISC OS machines
  4. ;   #   # #  # #     # #  #     # #  #   ___________________________________
  5. ;   #   # ####  ###  ##   #     # #  #
  6. ;   #   # #        # # #  #     # #  #    Please refer to the accompanying
  7. ;   ####   ### ####  #  # ##### # ###    documentation for conditions of use
  8. ;   ________________________________________________________________________
  9. ;
  10. ;   File:    Str.strcatcr.s
  11. ;   Author:  Copyright © 1994 Jason Williams
  12. ;   Version: 2.00 (24 Sep 1994)
  13. ;   Purpose: Concatenate two CR/NUL terminated strings - note that this will
  14. ;            change the terminator of the result to a NUL (0).
  15.  
  16.  
  17.         GET     ^.h.regdefs
  18.         GET     ^.h.swinos
  19.         GET     ^.h.macros
  20.  
  21.         PREAMBLE
  22.         STARTCODE strcatcr
  23. ;    extern char *strcatcr(char *s1, char *s2);
  24.  
  25.  
  26.         SUB       a3, a1, #1         ; a3 = pre-incrementing ptr to dest
  27. strcat_findend
  28.         LDRB      ip, [a3, #1]!      ; scan for the terminating char in dest
  29.         CMP       ip, #31
  30.         BGT       strcat_findend
  31.  
  32. strcat_copy
  33.         LDRB      ip, [a2], #1      ; a2 = post-incrementing  ptr to source
  34.         CMP       ip, #31
  35.         STRGTB    ip, [a3], #1      ; if char > 31, append to dest
  36.         BGT       strcat_copy       ;   and loop
  37.  
  38.         MOV       ip, #0            ; NULL terminate
  39.         STRB      ip, [a3]
  40.  
  41.         MOV       pc, lr            ; return(a1) (ptr to source)
  42.  
  43. ; ---
  44. ; Old code (by Ainsley Pereira)
  45. ;
  46. ;        STMFD     sp!,{v1,v2,lr}
  47. ;        MOV       v1,#0
  48. ;        MOV       v2,#0
  49. ;strcatcr_00
  50. ;        LDRB      ip,[a1,v1]
  51. ;        CMP       ip,#31
  52. ;        ADDGT     v1,v1,#1
  53. ;        BGT       strcatcr_00
  54. ;strcatcr_01
  55. ;        LDRB      ip,[a2,v2]
  56. ;        CMP       ip,#31
  57. ;        STRBGT    ip,[a1,v1]
  58. ;        ADDGT     v1,v1,#1
  59. ;        ADDGT     v2,v2,#1
  60. ;        BGT       strcatcr_01
  61. ;        MOV       ip,#0
  62. ;        STRB      ip,[a1,v1]
  63. ;        LDMFD     sp!, {v1,v2, pc}^
  64. ;
  65.  
  66.         END
  67.